package com.cus.tom.transfer.frag;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.cus.tom.transfer.databinding.TipDlgBinding;

public class TipDlg extends BaseDialogFragment {

    TipDlgBinding binding;
    String msg = "", ok = "";
    boolean check = false;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = TipDlgBinding.inflate(inflater, container, false);
        binding.msg.setText(msg);
        if (!TextUtils.isEmpty(ok)) {
            binding.ok.setText(ok);
        }
        if (check) {
            binding.check.setVisibility(View.VISIBLE);
        }
        binding.ok.setOnClickListener(v -> dismiss(true, binding.check.isChecked()));
        binding.cancel.setOnClickListener(v -> dismiss());
        return binding.getRoot();
    }

    public TipDlg setMsg(String s) {
        msg = s;
        return this;
    }

    public TipDlg setOk(String ok) {
        this.ok = ok;
        return this;
    }

    public TipDlg check(boolean bo) {
        check = bo;
        return this;
    }
}
